home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / foo / m-news.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-28  |  21.1 KB  |  598 lines

  1. /* Parameters for execution on a Sony/NEWS, for GDB, the GNU debugger.
  2.    Copyright (C) 1987, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. GDB is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GDB is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GDB; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* See following cpu type determination macro to get the machine type.
  21.   
  22. Here is an m-news.h file for gdb.  It supports the 68881 registers.
  23.                                            by hikichi@srava.sra.junet
  24.   
  25. * Support Sun assembly format instead of Motorola one.
  26. * Ptrace for handling floating register has a bug(before NEWS OS version 2.2),
  27. * After NEWS OS version 3.2, some of ptrace's bug is fixed.
  28.   But we cannot change the floating register(see adb(1) in OS 3.2) yet.
  29.  
  30. Here is an m-news800.h file for gdb version 2.6.  It supports the 68881
  31. registers.
  32.  
  33. /* Identify this machine */
  34. #ifndef sony_news
  35. #define sony_news
  36. #endif
  37.  
  38. /* determine the cpu type from machine type.  */
  39. #if defined(news1500)||defined(news1700)||defined(news1800)||defined(news1900)
  40. #  ifndef mc68020
  41. #    define mc68020
  42. #  endif /* not def mc68020 */
  43. #  ifndef mc68030
  44. #    define mc68030
  45. #  endif /* not def mc68030 */
  46. #else /* 1000 Series */
  47. #  if defined(news700)||defined(news800)||defined(news900)
  48. #    ifndef mc68020
  49. #    define mc68020
  50. #    endif 
  51. #  else /* 800 Series */
  52. /* unkown model ? */
  53. #  endif /* 800 Series */
  54. #endif /* 1000 Series */
  55.  
  56. /* Define the bit, byte, and word ordering of the machine.  */
  57. #define BITS_BIG_ENDIAN
  58. #define BYTES_BIG_ENDIAN
  59. #define WORDS_BIG_ENDIAN
  60.  
  61. /* Use GNU assembler instead of standard assembler */
  62. #define USE_GAS
  63.  
  64. /* Motorola assembly format */
  65. #ifndef USE_GAS
  66. #define MOTOROLA
  67. #endif
  68.  
  69. /* Doesn't have siginterrupt.  */
  70. #define NO_SIGINTERRUPT
  71.  
  72. #define HAVE_WAIT_STRUCT
  73.  
  74. /* Get rid of any system-imposed stack limit if possible.  */
  75.  
  76. #define SET_STACK_LIMIT_HUGE
  77.  
  78. /* Define this if the C compiler puts an underscore at the front
  79.    of external names before giving them to the linker.  */
  80.  
  81. #define NAMES_HAVE_UNDERSCORE
  82.  
  83. /* Symbols on this machine are in DBX format. */
  84. #define READ_DBX_FORMAT
  85.  
  86. /* We can't use "isatty" or "fileno" on this machine.  This isn't good,
  87.    but it will have to do.  */
  88. #define ISATTY(FP)    ((FP) == stdin || (FP) == stdout)
  89.  
  90. /* Offset from address of function to start of its code.
  91.    Zero on most machines.  */
  92.  
  93. #define FUNCTION_START_OFFSET 0
  94.  
  95. /* Advance PC across any function entry prologue instructions
  96.    to reach some "real" code.  */
  97.  
  98. #define SKIP_PROLOGUE(pc)   \
  99. { register int op = read_memory_integer (pc, 2);    \
  100.   if (op == 0047126)                    \
  101.     pc += 4;   /* Skip link #word */            \
  102.   else if (op == 0044016)                \
  103.     pc += 6;   /* Skip link #long */                    \
  104. }
  105.  
  106.  
  107. /* Immediately after a function call, return the saved pc.
  108.    Can't always go through the frames for this because on some machines
  109.    the new frame is not set up until the new function executes
  110.    some instructions.  */
  111.  
  112. #define SAVED_PC_AFTER_CALL(frame) \
  113. read_memory_integer (read_register (SP_REGNUM), 4)
  114.  
  115. /* THis is the amount to subtract from u.u_ar0
  116.    to get the offset in the core file of the register values. */
  117.  
  118. #define KERNEL_U_ADDR UADDR
  119.  
  120. /* Address of end of stack space.  */
  121.  
  122. #define STACK_END_ADDR  (0x80000000 - (UPAGES+CLSIZE)*NBPG)
  123.  
  124. /* Stack grows downward.  */
  125.  
  126. #define INNER_THAN <
  127.  
  128. /* Sequence of bytes for breakpoint instruction.  */
  129.  
  130. #define BREAKPOINT {0x4e, 0x4f}
  131.  
  132. /* Amount PC must be decremented by after a breakpoint.
  133.    This is often the number of bytes in BREAKPOINT
  134.    but not always.  */
  135.  
  136. #define DECR_PC_AFTER_BREAK 2
  137.  
  138. /* Nonzero if instruction at PC is a return instruction.  */
  139.  
  140. #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75)
  141.  
  142. /* Return 1 if P points to an invalid floating point value.  */
  143.  
  144. #define INVALID_FLOAT(p, len) 0   /* Just a first guess; not checked */
  145.  
  146. /* Largest integer type */
  147. #define LONGEST long
  148.  
  149. /* Name of the builtin type for the LONGEST type above. */
  150. #define BUILTIN_TYPE_LONGEST builtin_type_long
  151.  
  152. /* Say how long registers are.  */
  153.  
  154. #define REGISTER_TYPE long
  155.  
  156. /* Number of machine registers */
  157.  
  158. #define NUM_REGS 29
  159.  
  160. /* Initializer for an array of names of registers.
  161.    There should be NUM_REGS strings in this initializer.  */
  162.  
  163. #define REGISTER_NAMES  \
  164.  {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
  165.   "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \
  166.   "pc", "ps",  \
  167.   "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \
  168.   "fpcontrol", "fpstatus", "fpiaddr" }
  169.  
  170. /* Register numbers of various important registers.
  171.    Note that some of these values are "real" register numbers,
  172.    and correspond to the general registers of the machine,
  173.    and some are "phony" register numbers which are too large
  174.    to be actual register numbers as far as the user is concerned
  175.    but do serve to get the desired values when passed to read_register.  */
  176.  
  177. #define FP_REGNUM 14        /* Contains address of executing stack frame */
  178. #define SP_REGNUM 15        /* Contains address of top of stack */
  179. #define PC_REGNUM 16        /* Contains program counter */
  180. #define PS_REGNUM 17        /* Contains processor status */
  181. #define FP0_REGNUM 18        /* Floating point register 0 */
  182. #define FPC_REGNUM 26        /* 68881 control register */
  183.  
  184. /* before NEWSOS version 2.2 or more.  If you have a new OS,
  185.    redefine this macro in 'see m-newsos3.h'. */
  186. #define REGISTER_U_ADDR(addr, blockend, regno)        \
  187. {    if (regno <= FP_REGNUM) \
  188.       addr = blockend + 4 + regno * 4; \
  189.     else if (regno == SP_REGNUM) \
  190.       addr = blockend - 4 * 4; \
  191.     else if (regno <= PS_REGNUM) \
  192.       addr = blockend + (regno - PS_REGNUM) * 4; \
  193.     else if (regno < FPC_REGNUM) \
  194.       addr = blockend + 4 + 4 * 14 + 4 * 4 + (regno - FP0_REGNUM) * 12; \
  195.     else \
  196.       addr = blockend + 4 + 4 * 16 + (regno - FPC_REGNUM) * 4; \
  197. }
  198.  
  199. /* Total amount of space needed to store our copies of the machine's
  200.    register state, the array `registers'.  */
  201. #define REGISTER_BYTES (16*4+8*12+8+12)
  202.  
  203. /* Index within `registers' of the first byte of the space for
  204.    register N.  */
  205.  
  206. #define REGISTER_BYTE(N)  \
  207.  ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168    \
  208.   : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72    \
  209.   : (N) * 4)
  210.  
  211. /* Number of bytes of storage in the actual machine representation
  212.    for register N.  On the 68000, all regs are 4 bytes
  213.    except the floating point regs which are 12 bytes.  */
  214.  
  215. #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4)
  216.  
  217. /* Number of bytes of storage in the program's representation
  218.    for register N.  On the 68000, all regs are 4 bytes
  219.    except the floating point regs which are 8-byte doubles.  */
  220.  
  221. #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4)
  222.  
  223. /* Largest value REGISTER_RAW_SIZE can have.  */
  224.  
  225. #define MAX_REGISTER_RAW_SIZE 12
  226.  
  227. /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
  228.  
  229. #define MAX_REGISTER_VIRTUAL_SIZE 8
  230.  
  231. /* Nonzero if register N requires conversion
  232.    from raw format to virtual format.  */
  233.  
  234. #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8)
  235.  
  236. /* Convert data from raw format for register REGNUM
  237.    to virtual format for register REGNUM.  */
  238.  
  239. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO)    \
  240. { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM)    \
  241.     convert_from_68881 ((FROM), (TO));    \
  242.   else                    \
  243.     bcopy ((FROM), (TO), 4); }
  244.  
  245. /* Convert data from virtual format for register REGNUM
  246.    to raw format for register REGNUM.  */
  247.  
  248. #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO)    \
  249. { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM)    \
  250.     convert_to_68881 ((FROM), (TO));    \
  251.   else                    \
  252.     bcopy ((FROM), (TO), 4); }
  253.  
  254. /* Return the GDB type object for the "standard" data type
  255.    of data in register N.  */
  256.  
  257. #define REGISTER_VIRTUAL_TYPE(N) \
  258.  (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
  259.  
  260. /* Store the address of the place in which to copy the structure the
  261.    subroutine will return.  This is called from call_function. */
  262.  
  263. #define STORE_STRUCT_RETURN(ADDR, SP) \
  264.   { write_register (9, (ADDR)); }
  265.  
  266. /* Extract from an array REGBUF containing the (raw) register state
  267.    a function return value of type TYPE, and copy that, in virtual format,
  268.    into VALBUF.  */
  269.  
  270. /* when it return the floating value, use the FP0 in NEWS.  */
  271. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
  272.   { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
  273.       { \
  274.     REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \
  275.                    ®BUF[REGISTER_BYTE (FP0_REGNUM)], VALBUF); \
  276.       } \
  277.     else \
  278.       bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)); }
  279.  
  280. /* Write into appropriate registers a function return value
  281.    of type TYPE, given in virtual format.  */
  282.  
  283. /* when it return the floating value, use the FP0 in NEWS.  */
  284. #define STORE_RETURN_VALUE(TYPE,VALBUF) \
  285.   { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
  286.       { \
  287.     char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \
  288.     REGISTER_CONVERT_TO_RAW (FP0_REGNUM, VALBUF, raw_buf); \
  289.     write_register_bytes (FP0_REGNUM, \
  290.                   raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \
  291.       } \
  292.     else \
  293.       write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)); }
  294.  
  295. /* Extract from an array REGBUF containing the (raw) register state
  296.    the address in which a function should return its structure value,
  297.    as a CORE_ADDR (or an expression that can be used as one).  */
  298.  
  299. #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
  300.  
  301. /* Compensate for lack of `vprintf' function.  */
  302. #ifndef HAVE_VPRINTF
  303. #define vprintf(format, ap) _doprnt (format, ap, stdout)
  304. #endif /* not HAVE_VPRINTF */
  305.  
  306. /* Describe the pointer in each stack frame to the previous stack frame
  307.    (its caller).  */
  308.  
  309. /* FRAME_CHAIN takes a frame's nominal address
  310.    and produces the frame's chain-pointer.
  311.  
  312.    FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
  313.    and produces the nominal address of the caller frame.
  314.  
  315.    However, if FRAME_CHAIN_VALID returns zero,
  316.    it means the given frame is the outermost one and has no caller.
  317.    In that case, FRAME_CHAIN_COMBINE is not used.  */
  318.  
  319. /* In the case of the NEWS, the frame's nominal address
  320.    is the address of a 4-byte word containing the calling frame's address.  */
  321.  
  322. #define FRAME_CHAIN(thisframe)  \
  323.   (outside_startup_file ((thisframe)->pc) ? \
  324.    read_memory_integer ((thisframe)->frame, 4) :\
  325.    0)
  326.  
  327. #define FRAME_CHAIN_VALID(chain, thisframe) \
  328.   (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
  329.  
  330. #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
  331.  
  332. /* Define other aspects of the stack frame.  */
  333.  
  334. /* A macro that tells us whether the function invocation represented
  335.    by FI does not have a frame on the stack associated with it.  If it
  336.    does not, FRAMELESS is set to 1, else 0.  */
  337. #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
  338.   FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
  339.  
  340. #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
  341.  
  342. #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
  343.  
  344. #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
  345.  
  346. /* Return number of args passed to a frame.
  347.    Can return -1, meaning no way to tell.  */
  348.  
  349. #define FRAME_NUM_ARGS(val, fi)  \
  350. { register CORE_ADDR pc = FRAME_SAVED_PC (fi);            \
  351.   register int insn = 0177777 & read_memory_integer (pc, 2);    \
  352.   val = 0;                            \
  353.   if (insn == 0047757 || insn == 0157374)  /* lea W(sp),sp or addaw #W,sp */ \
  354.     val = read_memory_integer (pc + 2, 2);            \
  355.   else if ((insn & 0170777) == 0050217 /* addql #N, sp */    \
  356.        || (insn & 0170777) == 0050117)  /* addqw */        \
  357.     { val = (insn >> 9) & 7; if (val == 0) val = 8; }        \
  358.   else if (insn == 0157774) /* addal #WW, sp */            \
  359.     val = read_memory_integer (pc + 2, 4);            \
  360.   val >>= 2; }
  361.  
  362. /* Return number of bytes at start of arglist that are not really args.  */
  363.  
  364. #define FRAME_ARGS_SKIP 8
  365.  
  366. /* Put here the code to store, into a struct frame_saved_regs,
  367.    the addresses of the saved registers of frame described by FRAME_INFO.
  368.    This includes special registers such as pc and fp saved in special
  369.    ways in the stack frame.  sp is even more special:
  370.    the address we return for it IS the sp for the next frame.  */
  371.  
  372. #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs)        \
  373. { register int regnum;                            \
  374.   register int regmask;                            \
  375.   register CORE_ADDR next_addr;                        \
  376.   register CORE_ADDR pc;                        \
  377.   int nextinsn;                                \
  378.   bzero (&frame_saved_regs, sizeof frame_saved_regs);            \
  379.   if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \
  380.       && (frame_info)->pc <= (frame_info)->frame)                \
  381.     { next_addr = (frame_info)->frame;                    \
  382.       pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\
  383.   else                                   \
  384.     { pc = get_pc_function_start ((frame_info)->pc);             \
  385.       /* Verify we have a link a6 instruction next;            \
  386.      if not we lose.  If we win, find the address above the saved   \
  387.      regs using the amount of storage from the link instruction.  */\
  388.       if (044016 == read_memory_integer (pc, 2))            \
  389.     next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \
  390.       else if (047126 == read_memory_integer (pc, 2))            \
  391.     next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \
  392.       else goto lose;                            \
  393.       /* If have an addal #-n, sp next, adjust next_addr.  */        \
  394.       if ((0177777 & read_memory_integer (pc, 2)) == 0157774)        \
  395.     next_addr += read_memory_integer (pc += 2, 4), pc += 4;        \
  396.     }                                    \
  397.   /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */    \
  398.   regmask = read_memory_integer (pc + 2, 2);                \
  399.   /* But before that can come an fmovem.  Check for it.  */        \
  400.   nextinsn = 0xffff & read_memory_integer (pc, 2);            \
  401.   if (0xf227 == nextinsn                        \
  402.       && (regmask & 0xff00) == 0xe000)                    \
  403.     { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \
  404.       for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1)        \
  405.     if (regmask & 1)                        \
  406.           (frame_saved_regs).regs[regnum] = (next_addr -= 12);        \
  407.       regmask = read_memory_integer (pc + 2, 2); }            \
  408.   if (0044327 == read_memory_integer (pc, 2))                \
  409.     { pc += 4; /* Regmask's low bit is for register 0, the first written */ \
  410.       for (regnum = 0; regnum < 16; regnum++, regmask >>= 1)        \
  411.     if (regmask & 1)                        \
  412.           (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; }    \
  413.   else if (0044347 == read_memory_integer (pc, 2))            \
  414.     { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \
  415.       for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1)        \
  416.     if (regmask & 1)                        \
  417.           (frame_saved_regs).regs[regnum] = (next_addr -= 4); }        \
  418.   else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2)))        \
  419.     { regnum = 0xf & read_memory_integer (pc, 2); pc += 2;        \
  420.       (frame_saved_regs).regs[regnum] = (next_addr -= 4); }        \
  421.   /* fmovemx to index of sp may follow.  */                \
  422.   regmask = read_memory_integer (pc + 2, 2);                \
  423.   nextinsn = 0xffff & read_memory_integer (pc, 2);            \
  424.   if (0xf236 == nextinsn                        \
  425.       && (regmask & 0xff00) == 0xf000)                    \
  426.     { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \
  427.       for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1)        \
  428.     if (regmask & 1)                        \
  429.           (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12;    \
  430.       regmask = read_memory_integer (pc + 2, 2); }            \
  431.   /* clrw -(sp); movw ccr,-(sp) may follow.  */                \
  432.   if (0x426742e7 == read_memory_integer (pc, 4))            \
  433.     (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4);        \
  434.   lose: ;                                \
  435.   (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8;        \
  436.   (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame;        \
  437.   (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;        \
  438. }
  439.  
  440. /* Things needed for making the inferior call functions.  */
  441. /* On NEWS os 2.x ptrace cannot modify fp and floating registers.  */
  442. #define PTRACE_BUG
  443.  
  444. /* Push an empty stack frame, to record the current PC, etc.  */
  445. /* now ptrace has a bug to write floating register in old OS */
  446. #define PUSH_DUMMY_FRAME \
  447. { register CORE_ADDR sp = read_register (SP_REGNUM);            \
  448.   register int regnum;                            \
  449.   sp = push_word (sp, read_register (PC_REGNUM));            \
  450.   sp = push_word (sp, read_register (FP_REGNUM));            \
  451.   write_register (FP_REGNUM, sp);                    \
  452.   for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--)            \
  453.     sp = push_word (sp, read_register (regnum));            \
  454.   sp = push_word (sp, read_register (PS_REGNUM));            \
  455.   write_register (SP_REGNUM, sp);  }
  456.  
  457. /* Discard from the stack the innermost frame, restoring all registers.  */
  458.  
  459. #define POP_FRAME  \
  460. { register FRAME frame = get_current_frame ();                 \
  461.   register CORE_ADDR fp;                         \
  462.   register int regnum;                            \
  463.   struct frame_saved_regs fsr;                        \
  464.   struct frame_info *fi;                        \
  465.   fi = get_frame_info (frame);                         \
  466.   fp = fi->frame;                             \
  467.   get_frame_saved_regs (fi, &fsr);                    \
  468.   for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--)            \
  469.     if (fsr.regs[regnum])                        \
  470.       write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
  471.   if (fsr.regs[PS_REGNUM])                        \
  472.     write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
  473.   write_register (FP_REGNUM, read_memory_integer (fp, 4));        \
  474.   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));      \
  475.   write_register (SP_REGNUM, fp + 8);                    \
  476.   flush_cached_frames ();                         \
  477.   set_current_frame (create_new_frame (read_register (FP_REGNUM),    \
  478.                        read_pc ())); }
  479.  
  480. /* This sequence of words is the instructions
  481.      fmove.m #<f0-f7>,-(sp)
  482.      movem.l 0xfffc,-(sp)     ;; no save a6(fp) and a7(sp)
  483.      clr.w -(sp)
  484.      move.w ccr,-(sp)
  485.      /..* The arguments are pushed at this point by GDB;
  486.     no code is needed in the dummy for this.
  487.     The CALL_DUMMY_START_OFFSET gives the position of 
  488.     the following jsr instruction.  *../
  489.      jbsr (#32323232)
  490.      add.l #69696969,sp
  491.      bpt
  492.      nop
  493. Note this is 24 bytes.
  494. We actually start executing at the jsr, since the pushing of the
  495. registers is done by PUSH_DUMMY_FRAME.  If this were real code,
  496. the arguments for the function called by the jsr would be pushed
  497. between the moveml and the jsr, and we could allow it to execute through.
  498. But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done,
  499. and we cannot allow the moveml to push the registers again lest they be
  500. taken for the arguments.  */
  501.  
  502. #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
  503.  
  504. #define CALL_DUMMY_LENGTH 28
  505.  
  506. #define CALL_DUMMY_START_OFFSET 12
  507.  
  508. /* Insert the specified number of args and function address
  509.    into a call sequence of the above form stored at DUMMYNAME.  */
  510.  
  511. #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type)     \
  512. { *(int *)((char *) dummyname + 20) = nargs * 4;  \
  513.   *(int *)((char *) dummyname + 14) = fun; }
  514.  
  515. /* Interface definitions for kernel debugger KDB.  */
  516.  
  517. /* Map machine fault codes into signal numbers.
  518.    First subtract 0, divide by 4, then index in a table.
  519.    Faults for which the entry in this table is 0
  520.    are not handled by KDB; the program's own trap handler
  521.    gets to handle then.  */
  522.  
  523. #define FAULT_CODE_ORIGIN 0
  524. #define FAULT_CODE_UNITS 4
  525. #define FAULT_TABLE    \
  526. { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
  527.   0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
  528.   0, 0, 0, 0, 0, 0, 0, 0, \
  529.   SIGILL }
  530.  
  531. /* Start running with a stack stretching from BEG to END.
  532.    BEG and END should be symbols meaningful to the assembler.
  533.    This is used only for kdb.  */
  534.  
  535. #ifdef MOTOROLA
  536. #define INIT_STACK(beg, end)  \
  537. { asm (".globl end");         \
  538.   asm ("move.l $ end, sp");      \
  539.   asm ("clr.l fp"); }
  540. #else
  541. #define INIT_STACK(beg, end)  \
  542. { asm (".globl end");         \
  543.   asm ("movel $ end, sp");      \
  544.   asm ("clrl fp"); }
  545. #endif
  546.  
  547. /* Push the frame pointer register on the stack.  */
  548. #ifdef MOTOROLA
  549. #define PUSH_FRAME_PTR        \
  550.   asm ("move.l fp, -(sp)");
  551. #else
  552. #define PUSH_FRAME_PTR        \
  553.   asm ("movel fp, -(sp)");
  554. #endif
  555.  
  556. /* Copy the top-of-stack to the frame pointer register.  */
  557. #ifdef MOTOROLA
  558. #define POP_FRAME_PTR  \
  559.   asm ("move.l (sp), fp");
  560. #else
  561. #define POP_FRAME_PTR  \
  562.   asm ("movl (sp), fp");
  563. #endif
  564.  
  565. /* After KDB is entered by a fault, push all registers
  566.    that GDB thinks about (all NUM_REGS of them),
  567.    so that they appear in order of ascending GDB register number.
  568.    The fault code will be on the stack beyond the last register.  */
  569.  
  570. #ifdef MOTOROLA
  571. #define PUSH_REGISTERS        \
  572. { asm ("clr.w -(sp)");          \
  573.   asm ("pea (10,sp)");          \
  574.   asm ("movem $ 0xfffe,-(sp)"); }
  575. #else
  576. #define PUSH_REGISTERS        \
  577. { asm ("clrw -(sp)");          \
  578.   asm ("pea 10(sp)");          \
  579.   asm ("movem $ 0xfffe,-(sp)"); }
  580. #endif
  581.  
  582. /* Assuming the registers (including processor status) have been
  583.    pushed on the stack in order of ascending GDB register number,
  584.    restore them and return to the address in the saved PC register.  */
  585.  
  586. #ifdef MOTOROLA
  587. #define POP_REGISTERS          \
  588. { asm ("subi.l $8,28(sp)");     \
  589.   asm ("movem (sp),$ 0xffff"); \
  590.   asm ("rte"); }
  591. #else
  592. #define POP_REGISTERS          \
  593. { asm ("subil $8,28(sp)");     \
  594.   asm ("movem (sp),$ 0xffff"); \
  595.   asm ("rte"); }
  596. #endif
  597.  
  598.